/*
 * @Author: your name
 * @Date: 2021-03-13 14:18:06
 * @LastEditTime: 2021-03-22 15:14:48
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \djc\js\item.js
 */




require(['./config'], () => {
    require(['template', 'header', 'footer', 'jquery'], (template) => {
        class yyk_item {
            constructor() {
                this.bd();
                this.img_ewm();
                this.getData()
            }
            bd() {
                // 商品详情 == 商品放大
                $('.bd').click(() => {
                    $('.bd_yc').css('display', 'block')
                })
                $('.bd_xs').click(() => {
                    $('.bd_yc').css('display', 'none')
                })
            }
            img_ewm() {
                // 手机购买 == 显示二维码
                $('.img_ewm').mouseover(() => {
                    $('.img_ewms').css('display', 'block')
                })
                $('.img_ewm').mouseout(() => {
                    $('.img_ewms').css('display', 'none')
                })
            }
            getData(){
                $.ajax({
                    url:'http://rap2api.taobao.org/app/mock/data/1911363',
                }).then(res=>{
                    this.listData(res);
                    this.addCar()
                })
            }
            listData(res){
                const {data} = res;
                //console.log(data)
                $('.get_list').html(template('gl',{data}));
            }
            addCar(){
                $('.addCar').click(function(){
                    let list = {};
                    let arr = [];
                    let id = $('.addCar').parent().attr('listId')
                    list.name = $('.gettitle').text();
                    list.price = $('.getprice').text() - 0;
                    list.id = id;
                    arr[0] = list;
                    console.log(arr)
                    localStorage.setItem('list',JSON.stringify(arr))
                })
            }
        }
        return new yyk_item()
    })
})